package com.ruoyi.inventory.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.ruoyi.common.core.page.Pages;
import com.ruoyi.common.core.page.Query;
import com.ruoyi.common.query.QueryTool;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.inventory.mapper.ProgressDetailMapper;
import com.ruoyi.inventory.domain.ProgressDetail;
import com.ruoyi.inventory.service.IProgressDetailService;

/**
 * 工序详情Service业务层处理
 *
 * @author xwj
 * @date 2024-06-17
 */
@Service
public class ProgressDetailServiceImpl extends ServiceImpl<ProgressDetailMapper, ProgressDetail> implements IProgressDetailService {
    @Autowired
    private ProgressDetailMapper progressDetailMapper;

    /**
     * 查询工序详情
     *
     * @param id 工序详情主键
     * @return 工序详情
     */
    @Override
    public ProgressDetail selectProgressDetailById(Long id) {
        return progressDetailMapper.selectProgressDetailById(id);
    }

    /**
     * 查询工序详情列表
     *
     * @param progressDetail 工序详情
     * @return 工序详情
     */
    @Override
    public List<ProgressDetail> selectProgressDetailList(ProgressDetail progressDetail) {
        return progressDetailMapper.selectProgressDetailList(progressDetail);
    }

    /**
     * 新增工序详情
     *
     * @param progressDetail 工序详情
     * @return 结果
     */
    @Override
    public ProgressDetail insertProgressDetail(ProgressDetail progressDetail) {

        //  progressDetailMapper.insertProgressDetail(progressDetail);
        save(progressDetail);
        return progressDetail;
    }

    /**
     * 修改工序详情
     *
     * @param progressDetail 工序详情
     * @return 结果
     */
    @Override
    public ProgressDetail updateProgressDetail(ProgressDetail progressDetail) {

        //  progressDetailMapper.updateProgressDetail(progressDetail);
        updateById(progressDetail);
        return progressDetail;
    }

    /**
     * 批量删除工序详情
     *
     * @param ids 需要删除的工序详情主键
     * @return 结果
     */
    @Override
    public int deleteProgressDetailByIds(Long[] ids) {
        return progressDetailMapper.deleteProgressDetailByIds(ids);
    }

    /**
     * 条件删除
     * @param progressDetail 工序详情
     * @return
     */
    @Override
    public int delete(ProgressDetail progressDetail) {
        QueryWrapper<ProgressDetail> qw = new QueryWrapper<>();
        QueryTool.condition(qw, progressDetail);
        return baseMapper.delete(qw);
    }

    /**
     * mp分页
     * @param progressDetail 工序详情
     * @return
     */
    @Override
    public Pages<ProgressDetail> queryPage(ProgressDetail progressDetail) {
        QueryWrapper<ProgressDetail> qw = new QueryWrapper<>();
        QueryTool.condition(qw, progressDetail);
        IPage<ProgressDetail> ipage = new Query<ProgressDetail>().getPage(progressDetail);

        IPage<ProgressDetail> page = this.page(
                ipage,
                qw
        );
        return new Pages<>(page);
    }

    /**
     * 删除工序详情信息
     *
     * @param id 工序详情主键
     * @return 结果
     */
    @Override
    public int deleteProgressDetailById(Long id) {
        return progressDetailMapper.deleteProgressDetailById(id);
    }
}
